<?php

namespace app\admin\controller;

use utils\Auth;
use utils\Config;

class Index extends Common
{
    /**
     * 后台首页
     * @return string
     * @throws \Exception
     */
    public function index()
    {
        $info = $this->getInfo();

        $config = Config::get();

        $menu = $this->recursive_make_tree(Auth::getNavMenu());
        $this->assign(compact('info', 'config', 'menu'));
        return $this->view->fetch();
    }

    /**
     * 系统主页
     * @return string
     * @throws \Exception
     */
    public function main()
    {
        $config = [
            'url' => $_SERVER['HTTP_HOST'],
            'document_root' => $_SERVER['DOCUMENT_ROOT'],
            'server_os' => PHP_OS,
            'server_port' => $_SERVER['SERVER_PORT'],
            'server_ip' => $_SERVER['SERVER_ADDR'],
            'server_soft' => $_SERVER['SERVER_SOFTWARE'],
            'php_version' => PHP_VERSION,
            'max_upload_size' => ini_get('upload_max_filesize')
        ];

        $info = $this->getInfo();

        $this->assign(compact('info', 'config'));
        return $this->view->fetch();
    }

    public function quit()
    {
        session('aid', null);
        header('location:' . url('logins/index'));
        exit;
    }

    public function demo()
    {
        dump(error_get_last());
    }
}